package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.Travel;
import cn.wolfcode.wolf2w.query.StrategyQuery;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.service.ITravelService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/destinations")
public class DestinationsController {
   @Autowired
    private IRegionService regionService;
   @Autowired
   private IDestinationService destinationService;
   @Autowired
   private IStrategyService strategyService;
   @Autowired
   private ITravelService travelService;

   @GetMapping("/hotRegion")
    public Object hotRegion(){
       List hot =  regionService.hotRegion();
       return JsonResult.success(hot);
   }

   @GetMapping("/search")
    public Object search(String regionId){
       List destination = destinationService.queryDestinationByRegionId(regionId);
       return JsonResult.success(destination);
   }

    /**
     * 导航吐司
     * @param destId
     * @return
     */
    @GetMapping("/toasts")
    public Object toasts(String destId){
        List list = destinationService.queryToasts(destId);
        return JsonResult.success(list);
    }

    /**
     * 找当前目的地对应的攻略分类以及分类下的所有攻略
     * @param destId
     * @return
     */
    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        List list = destinationService.queryStrategyTheme(destId);
        return JsonResult.success(list);
    }


    /**
     * 根据destId寻找所有相关的前三名攻略
     * @param destId
     * @return
     */
    @GetMapping("/strategies/viewnumTop3")
    public Object strategies(String destId){
        List<Strategy> strategies = strategyService.findByDestIdTon3(destId);
        return JsonResult.success(strategies);
    }

    /**
     * 根据destId寻找所有相关的点击量前三名游记
     * @param destId
     * @return
     */
    @GetMapping("/travels/viewnumTop3")
    public Object strategiess(String destId){
        List<Travel> strategies = travelService.findByDestIdTon3(destId);
        return JsonResult.success(strategies);
    }


    @GetMapping("/list")
    public Object list(){
        return JsonResult.success(destinationService.list());
    }
}
